import request from "@/request/index";

// 类型：会员注册接口
export interface resUserRegisterType {
  code: number;
  message: string;
  data: string;
  ok?: boolean;
}

// 请求：会员注册接口
export const reqUserRegister = (phone: string) => {
  return request.get<any, any>(`/sms/send/${phone}`);
};

// 类型：会员登录接口
export interface reqUserLoginType {
  code: string | undefined;
  phone: string | undefined;
}

//  请求：会员登录接口
export const reqUserLogin = (data: reqUserLoginType) => {
  return request.post<any, any>(`/user/login`, data);
};

// 类型1.订单状态
export interface authStatusItemType {
  comment: string;
  status: number;
}

// 类型2:订单分页列表
export interface orderRecordsItemType {
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: {
    orderStatusString: string;
  };
  userId: number;
  outTradeNo: string;
  hoscode: string;
  hosname: string;
  depcode: string;
  depname: string;
  scheduleId: null;
  title: string;
  reserveDate: string;
  reserveTime: number;
  patientId: number;
  patientName: string;
  patientPhone: string;
  hosRecordId: string;
  number: 1;
  fetchTime: string;
  fetchAddress: string;
  amount: number;
  quitTime: string;
  orderStatus: number;
}

export interface orderListType {
  records: orderRecordsItemType[];
  total: number;
  size: number;
  current: number;
  orders: [];
  hitCount: boolean;
  searchCount: boolean;
  pages: number;
}

// 获取订单分页列表query参数类型
export interface authInfoType {
  userId: number;
  outTradeNo: string;
  patientId: number;
  patientName: string;
  keyword: string;
  orderStatus: string;
  reserveDate: string;
  createTimeBegin: string;
  createTimeEnd: string;
}

// 类型3:地址信息类型
export interface addressType {
  id: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: {};
  parentId: number;
  name: string;
  value: string;
  dictCode: null;
  hasChildren: boolean;
}

// 类型4:会员用户信息类型
export interface userInfoType {
  id: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: {};
  openid: string;
  nickName: string;
  phone: string;
  name: string;
  certificatesType: string;
  certificatesNo: string;
  certificatesUrl: string;
  authStatus: number;
  status: number;
}

// 类型5.添加实名信息类型
export interface addUserType {
  certificatesNo: string;
  certificatesType: string;
  certificatesUrl: string;
  name: string;
}

// 类型6.获取就诊人信息
export interface patientInfoItemType {
  id: number;
  createTime?: string;
  updateTime?: string;
  isDeleted: number;
  param: {
    certificatesTypeString: string;
    contactsCertificatesTypeString: string;
    cityString: string;
    fullAddress: string;
    districtString: string;
    provinceString: string;
  };
  userId: number;
  name: string;
  certificatesType: string;
  certificatesNo: string;
  sex: number;
  birthdate: string;
  phone: string;
  isMarry: number;
  provinceCode: string;
  cityCode: string;
  districtCode: string;
  address: string;
  contactsName: string;
  contactsCertificatesType: string;
  contactsCertificatesNo: string;
  contactsPhone: string;
  isInsure: number;
  cardNo: string;
  status: string;
}

// 类型7.添加就诊人类型
export interface addPatientType {
  address: string;
  addressSelected: string[];
  birthdate: string;
  certificatesNo: string;
  certificatesType: string;
  id: number;
  isInsure: number;
  isMarry: number;
  name: string;
  phone: string;
  sex: number;
  contactsCertificatesNo?: string;
  contactsCertificatesType?: string;
  contactsName?: string;
  contactsPhone?: string;
}

// 类型8.根据省份id获取城市列表类型
export interface cityItemType {
  id: number;
  createTime: string;
  updateTime: string;
  isDeleted: number;
  param: {};
  parentId: number;
  name: string;
  value: string;
  dictCode: string;
  hasChildren: boolean;
}

// 类型9.修改就诊人信息类型
export interface updatePatientType {
  address: string;
  birthdate: string;
  cardNo: string;
  certificatesNo: string;
  certificatesType: string;
  cityCode: string;
  contactsCertificatesNo: string;
  contactsCertificatesType: string;
  contactsName: string;
  contactsPhone: string;
  createTime: string;
  districtCode: string;
  id: number;
  isDeleted: number;
  isInsure: number;
  isMarry: number;
  name: string;
  param: {
    certificatesTypeString?: string;
    contactsCertificatesTypeString?: string;
    cityString?: string;
    fullAddress?: string;
    districtString?: string;
    provinceString?: string;
  };
  phone: string;
  provinceCode: string;
  sex: number;
  status: string;
  updateTime: string;
  userId: number;
}

// 请求1.获取订单状态
export const reqAuthStatusList = () => {
  return request.get<any, authStatusItemType[]>(
    `/order/orderInfo/auth/getStatusList`
  );
};

// 类型：会员登录
export interface reqUserLoginType {
  code: string | undefined;
  phone: string | undefined;
}

interface resUserWXSweep {
  redirectUri: string;
  appid: string;
  scope: string;
  state: string;
}
// 请求：会员扫码接口
export const reqUserWXSweep = (url: string) => {
  return request.get<any, resUserWXSweep>(
    //                            后端要求的参数
    `/user/weixin/getLoginParam?wxRedirectUri=${url}`
  );
};

// 请求2.获取挂号订单分页列表
export const reqOrderList = (page: number, limit: number) => {
  return request.get<any, orderListType>(
    `/order/orderInfo/auth/${page}/${limit}`
  );
};

// 请求3.请求地址信息
export const reqAddressList = (parentId: number) => {
  return request.get<any, addressType[]>(
    `/cmn/dict/findByParentId/${parentId}`
  );
};

// 请求4.请求会员用户信息
export const reqUserInfo = () => {
  return request.get<any, userInfoType>(`/user/auth/getUserInfo`);
};

// 请求5.添加实名认证信息
export const reqAddUser = (data: addUserType) => {
  return request.post<any, any>(`/user/auth/userAuah`, data);
};

// 请求6.获取就诊人列表
export const reqPatientList = () => {
  return request.get<any, updatePatientType[]>(`/user/patient/auth/findAll`);
};

// 请求7.新增就诊人
export const reqAddPatient = (data: addPatientType) => {
  return request.post<any, any>(`/user/patient/auth/save`, data);
};

// 请求8.根据省份id获取城市信息
export const reqCityList = (parentId: number) => {
  return request.get<any, cityItemType[]>(
    `/cmn/dict/findByParentId/${parentId}`
  );
};

// 请求9.修改就诊人信息
export const reqUpdatePatient = (patient: patientInfoItemType) => {
  return request.put<any, any>(`/user/patient/auth/update`, patient);
};

// 请求10.请求就诊人
export const reqPatientAuth = (id: number) => {
  return request.get<any,patientInfoItemType>(`/user/patient/auth/get/${id}`);
};

// 请求11.删除就诊人
export const reqDeletePatient = (id: number) => {
  return request.delete<any, any>(`/user/patient/auth/remove/${id}`);
};

// 请求12.获取就诊人挂号详情
export const reqOrderInfo = (id:number)=>{
  return request.get<any,orderRecordsItemType>(`/order/orderInfo/auth/getOrderInfo/${id}`)
}

// 请求13.获取微信支付二维码
export const reqPayCode = (orderId:number)=>{
  return request.get(`/api/order/weixin/createNative/${orderId}`)
}
